package com.neusoft.elm;

import com.neusoft.elm.po.Admin;
import com.neusoft.elm.view.AdminView;
import com.neusoft.elm.view.AdminViewImpl;
import com.neusoft.elm.view.BusinessView;
import com.neusoft.elm.view.BusinessViewImpl;

import java.util.Scanner;

public class ElmAdminEntry {
    public static void main(String[] args) {
        work();
    }
        public static void work() {
            Scanner sc = new Scanner(System.in);
            System.out.println("-------------------------------------------------------------");
            System.out.println("|\t\t\t\t\t 小源©的饿了么后台管理系统 \t\t\t\t\t|");
            System.out.println("-------------------------------------------------------------");

            AdminView adminView = new AdminViewImpl();
            BusinessView businessView = new BusinessViewImpl();
            Admin admin = adminView.login();
            //登录
            if(admin != null){
                int menu = 0;
                while(menu != 5){
                    System.out.println("-------------------------------------------------------------");
                    System.out.println("|                欢迎使用小源©的饿了么后台管理系统                |");
                    System.out.println("-------------------------------------------------------------");
                    System.out.println("1.所有商家列表\t2.搜索商家\t3.新建商家\t4.删除商家\t5.退出系统");
                    System.out.println("-------------------------------------------------------------");
                    System.out.println("请输入您的选择:");
                    menu = sc.nextInt();
                    switch(menu){
                        case 1:
                            businessView.listBusinessAll();
                            break;
                        case 2:
                            businessView.listBusiness();
                            break;
                        case 3:
                            businessView.saveBusiness();
                            break;
                        case 4:
                            businessView.removeBusiness();
                            break;
                        case 5:
                            System.out.println("---------<欢迎下次使用小源©的饿了么后台管理系统>---------");
                            break;
                        default:
                            System.out.println("!!!请输入正确的选项!!!");
                            break;
                    }
                }
            }else{
                System.out.println("管理员<名称>或<密码>输入错误!!!");
                System.out.println("---------<欢迎下次使用小源©的饿了么后台管理系统>---------");
            }
        }
}
